package il.ac.technion.cs236700.address_book;

import il.ac.technion.cs236700.utils.Misc;

/**
 * An immutable object representing the basic details of a person
 */
public class Person {
   /**
    * First name
    */
   public final String firstName;
   
   /**
    * Last name
    */
   public final String lastName;
   
   /**
    * Title (Mr, Mrs, ...)
    */
   public final String title;
   
   public Person(String firstName_, String lastName_, String title_) {
      firstName = firstName_;
      lastName = lastName_;
      title = title_;
   }

   @Override
   public int hashCode() {
      return Misc.hash(firstName, lastName);    
   }
   
   @Override
   public boolean equals(Object o) {
      Person that = Misc.cast(this, o);
      return that != null && Misc.eq(firstName, that.firstName)
         && Misc.eq(lastName, that.lastName);
   }
   
   @Override
   public String toString() {
      return (title + " " + firstName + " " + lastName).trim();
   }
}
